package org.bigjava.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.*;

//实现WebMvcConfigurer接口可以来扩展SpringMVC的功能
//@EnableWebMvc   //完全接管SpringMVC
@Configuration
public class MyMvcConfig implements WebMvcConfigurer {

    @Override
    public void addViewControllers(ViewControllerRegistry registry){
        registry.addViewController("/").setViewName("denglu");
        registry.addViewController("/denglu.html").setViewName("denglu");
        registry.addViewController("ljfl.html").setViewName("ljfl");
        registry.addViewController("gly.html").setViewName("gly");
        registry.addViewController("glyxx.html").setViewName("glyxx");

        registry.addViewController("tzggtj.html").setViewName("tzggtj");
        registry.addViewController("lajitj.html").setViewName("lajitj");

        registry.addViewController("wytj.html").setViewName("wytj");
        registry.addViewController("wuye.html").setViewName("wuye");
        registry.addViewController("yezhu.html").setViewName("yezhu");
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new LoginInterceptor()).addPathPatterns("/**")//拦截所有请求，包括静态资源文件
                .excludePathPatterns("/","/**/denglu", "/css/**", "/images/**", "/js/**", "/fonts/**"); //放行登录页，登陆操作，静态资源
    }
}
